
function loadObject(toRootPath, objId, scope) {
	var r = new ResourceBundle();
	r._contentPanel = document.getElementById("_content");
	r._baseId = objId + "." + scope;
  r.add("content", toRootPath + objId + "." + scope);
  r.add("xslt", "../style/meta_content.xsl");
  r.onCompleted = function() {
  	this.content.transform(this.xslt, this._contentPanel);
  	this._contentPanel.parentNode.id = this._baseId;
  };
  r.load();
}

function loadContent(url) {
	var r = new ResourceBundle();
	r._contentPanel = document.getElementById("_content");
  r.add("content", url);
  r.add("xslt", "../style/meta_content.xsl");
  r.onCompleted = function() {
  	this.content.transform(this.xslt, this._contentPanel);
  };
  r.load();
}

// TODO: implement a better extension mechanism... for now just overwrite.
if (typeof EditSelection == "function") {
	EditSelection.prototype.perform = function() {
		if (this.entityView.dom.element.className == "folder")
		  window.location.href = "cosmos.view?objId=" + this.entityView.entity.objId;
		else if (this.entityView.dom.element.className == "object")
		  loadObject("./../../..", this.entityView.entity.objId, "cosmos");
		else
		  Doc().editorPanel.open();
	}
}
